#include<iostream>
#include<list>
using namespace std;
int main(){
	int n,m,b,c,i,j,k;
	cin>>n>>m;
	list<int>a[n];
	while(m--){
		cin>>b>>c;
		a[b-1].push_back(c); 
	}
	for(i=0;i<n;++i){
		for(list<int>::iterator it=a[i].begin();it!=a[i].end();++it)
			cout<<(*it)<<" ";
		cout<<endl;
	}
	return 0;
}